Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add BrazilianCrux scale #158

Merged
merged 1 commit into from
Nov 9, 2023
Merged

feat: add BrazilianCrux scale #158

merged 1 commit into from
Nov 9, 2023

Conversation

enapupe
Copy link
Contributor

@enapupe enapupe commented Nov 7, 2023

hey guys, I think this is ready to be reviewed.
My changes were based on the norwegian scale.

I did a minor "API" change in the GradeScale types to accomodate the actual list of grades, that was necessary to handle cases where a slash grade was not the next logical grade.

I suggest we start using a code formatter like prettier, life is too short to manually adjust code looks.

Copy link

github-actions bot commented Nov 7, 2023

Coverage report

Statements coverage not met for global: expected <=999999 not covered statements, but got 608

St.
Category Percentage Covered / Total
🟢 Statements
87.48% (+1.09% 🔼)
608/695
🟡 Branches
67.54% (+2.22% 🔼)
129/191
🟡 Functions
79.87% (+0.45% 🔼)
119/149
🟢 Lines
86.67% (+1.1% 🔼)
559/645
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢 scales/brazilian.ts 98.33% 88.89% 91.67% 98.15%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢 index.ts 100% 100%
36.84% (-2.05% 🔻)
100%

Test suite run success

268 tests passing in 17 suites.

Report generated by 🧪jest coverage report action from 05900e2

@musoke musoke linked an issue Nov 9, 2023 that may be closed by this pull request
5 tasks
Copy link
Collaborator

@musoke musoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

How familiar are you with Brazillian grades? I am not, so I will defer to you on much of this if you're a local.

I have left some comments on details inline. Here are a couple more general comments:

Name of scale

Wikipedia says that there are at least two scales used in Brazil. The one you have implemented is what they call the "Brazilian technical scale". Should the name in sandbag be something like BrazilianTechnical? This will reduce confusion if we add additional Brazilian scales later.

New field on GradeScale

Please don't take this as negative feedback, it's mostly me trying to understand whether we can simplfy other parts of the library.

I did a minor "API" change in the GradeScale types to accomodate the actual list of grades, that was necessary to handle cases where a slash grade was not the next logical grade.

Could we clarify why this new field is needed?

As far as I can tell you're using it to avoid duplicating array definitions in src/scales/brazilian.ts and src/index.ts. Is that correct?
If so, why are those two arrays defined? My understanding is

  • In src/scales/brazilian.ts, the array allows checking that slash grades are consecutive. This makes a lot of sense. Thanks for adding a check that most of the other scales are missing 😄.

  • In src/index.ts, you added the array to freeClimbing for consistency with other scales.

Is that correct?

There may be something we can simplify here: it isn't clear to me why we have defined the arrays in src/index.ts for other scales. @vnugent, do you have some insight here? Is

sandbag/src/index.ts

Lines 273 to 286 in d5c4170

export const freeClimbing = {
clean: {
yds: YDS_ARRAY,
class: CLASS_ARRAY,
britishTech: BRITISH_TECH_ARRAY,
britishAdj: BRITISH_ADJ_ARRAY,
French: FRENCH_ARRAY,
UIAA: UIAA_ARRAY,
Ewbank: EWBANK_ARRAY,
Saxon: SAXON_ARRAY,
Norwegian: NORWAY_ARRAY
},
community: {}
}
vestigial? These arrays aren't used internally. Maybe it is useful to expose these in the API, but the current definitions are wrong and/or missing. The analogous array bouldering is empty and ice, aid, etc aren't even defined. The current tests are nearly tautological.

Summary of sources on Brazillian grades (mostly for myself)

src/data/routes.csv Outdated Show resolved Hide resolved
src/data/routes.csv Show resolved Hide resolved
src/scales/brazilian.ts Show resolved Hide resolved
README.md Show resolved Hide resolved
src/data/routes.csv Show resolved Hide resolved
src/__tests__/scales/brazilian.ts Outdated Show resolved Hide resolved
src/__tests__/scales/brazilian.ts Outdated Show resolved Hide resolved
@musoke
Copy link
Collaborator

musoke commented Nov 9, 2023

I suggest we start using a code formatter like prettier, life is too short to manually adjust code looks.

I am also a fan of code formatters. Most of OpenBeta's repos already use ts-standard - please open a separate issue or PR if you think that isn't enough.

@enapupe
Copy link
Contributor Author

enapupe commented Nov 9, 2023

I suggest we start using a code formatter like prettier, life is too short to manually adjust code looks.

I am also a fan of code formatters. Most of OpenBeta's repos already use ts-standard - please open a separate issue or PR if you think that isn't enough.

To be honest I haven't paid much attention to it, I remember I quickly runned it with --fix and didn't noticed it also formatted the code besides checking for types.
I guess one code formatter is sufficient :)

@enapupe
Copy link
Contributor Author

enapupe commented Nov 9, 2023

As far as I can tell you're using it to avoid duplicating array definitions in src/scales/brazilian.ts and src/index.ts. Is that correct?

Yes, exactly. I was trying to keep things consistent while not duplicating that array. The exposed API in somewhat unknown to me so that's why I did that change to access the array. Another option that crossed my mind was to actually generate that array from the json file, just getting the grades (ordered) and making it a set (i.e. removing dupes). Then it's automatically generated from within.

@enapupe
Copy link
Contributor Author

enapupe commented Nov 9, 2023

Wikipedia says that there are at least two scales used in Brazil. The one you have implemented is what they call the "Brazilian technical scale". Should the name in sandbag be something like BrazilianTechnical? This will reduce confusion if we add additional Brazilian scales later.

This information may be outdated, currently there's a single scale used in Brazil. In 2007 the brazilian National Confederation of Mountaineering and Climbing has published this spec and incentivized its use as the only standard

@enapupe
Copy link
Contributor Author

enapupe commented Nov 9, 2023

@musoke thank you for the throughout review! Really appreciate it.

How familiar are you with Brazillian grades? I am not, so I will defer to you on much of this if you're a local.

I'm brazilian and have been climbing around the country the last 10 years, the brazilian spec is not really that complex, but there are many misleading informations out there, especially from english sources. I think that's because in the past there was no official source of truth, but that was way before I started climbing so I can't tell for sure.

@enapupe
Copy link
Contributor Author

enapupe commented Nov 9, 2023 via email

@musoke
Copy link
Collaborator

musoke commented Nov 9, 2023

Wikipedia says that there are at least two scales used in Brazil. The one you have implemented is what they call the "Brazilian technical scale". Should the name in sandbag be something like BrazilianTechnical? This will reduce confusion if we add additional Brazilian scales later.

This information may be outdated, currently there's a single scale used in Brazil. In 2007 the brazilian National Confederation of Mountaineering and Climbing has published this spec and incentivized its use as the only standard

Searching in English wasn't sufficient to find that very clear and thorough spec 😆
Thank you for the links and detailed explanation!

Could you add a link to the spec in a docstring for const Brazilian? Then the intended behaviour will be clearer to anyone who uses this or changes it in the future.

Does anyone use grades that differ from the spec in ways that matter? For example, in old guidebooks? Are there routes whose consensus grade is non-compliant?
I think we should lean descriptivist if real-world grades diverge from the spec.

@musoke
Copy link
Collaborator

musoke commented Nov 9, 2023

As far as I can tell you're using it to avoid duplicating array definitions in src/scales/brazilian.ts and src/index.ts. Is that correct?

Yes, exactly. I was trying to keep things consistent while not duplicating that array. The exposed API in somewhat unknown to me so that's why I did that change to access the array. Another option that crossed my mind was to actually generate that array from the json file, just getting the grades (ordered) and making it a set (i.e. removing dupes). Then it's automatically generated from within.

Yes, that part of the exposed API is mysterious to me too. As far as I can tell, it is leftover from early versions. Let's keep what you wrote and address the other issues later.

@enapupe
Copy link
Contributor Author

enapupe commented Nov 9, 2023

Does anyone use grades that differ from the spec in ways that matter? For example, in old guidebooks? Are there routes whose consensus grade is non-compliant?

People often mix arabic/romans for single pitch sports route, which is wrong and should not be encouraged if we want to keep things consistent/within the spec.
Aside from that, I don't have any relevant information/knowledge. I'd have to research old magazines maybe, but I'm not sure if that's relevant.

@musoke
Copy link
Collaborator

musoke commented Nov 9, 2023

Does anyone use grades that differ from the spec in ways that matter? For example, in old guidebooks? Are there routes whose consensus grade is non-compliant?

People often mix arabic/romans for single pitch sports route, which is wrong and should not be encouraged if we want to keep things consistent/within the spec. Aside from that, I don't have any relevant information/knowledge. I'd have to research old magazines maybe, but I'm not sure if that's relevant.

Arabic -> Roman is a straightforward mapping, so likely no information loss there. Let's not worry about it if the edge cases are obscure.

Copy link
Collaborator

@musoke musoke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! You even linked the archive.org copy of the spec.

I'm happy for you to merge.

@enapupe enapupe merged commit d9e2059 into OpenBeta:develop Nov 9, 2023
3 checks passed
@musoke
Copy link
Collaborator

musoke commented Nov 9, 2023

@all-contributors add @enapupe for code and ideas

Copy link
Contributor

@musoke

I've put up a pull request to add @enapupe! 🎉

@musoke musoke changed the title feat: add brazilian scale feat: add BrazilianCrux scale Nov 9, 2023
musoke added a commit that referenced this pull request Nov 9, 2023
Tag and release changes from #158
@musoke musoke mentioned this pull request Nov 9, 2023
musoke added a commit that referenced this pull request Nov 9, 2023
[npm publish] release BrazilianCrux

Tag and release changes from #158
musoke added a commit that referenced this pull request Nov 9, 2023
Tag and release changes from #158
musoke added a commit that referenced this pull request Nov 9, 2023
Tag and release changes from #158
@musoke musoke mentioned this pull request Nov 10, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add Brazilian grades
2 participants